home *** CD-ROM | disk | FTP | other *** search
/ F1 Licenseware / F1 Licenseware - Volume 1.iso / disks / 003.dms / 003.adf / chapter5.txt next >
Text File  |  1992-09-02  |  8KB  |  219 lines

  1.  
  2.               The Absolute Beginners Guide To Amos
  3.               -------------------------------------
  4.                          Chapter Five
  5.                          -------------
  6.  
  7. In this chapter we are going to discover the mysteries of loading a picture
  8. from disk and displaying it on screen, before we can actually get around to
  9. this there are a few important things you must learn, the first is about 
  10. screens and the second is strings, here we go.
  11.  
  12. SCREENS:
  13. --------
  14. Amos has an excellent range of screen commands where the user can do almost
  15. anything.  We can create custom screens changing the size, amount of colours
  16. width and height and  other things.  We are not going to delve too deeply
  17. here as it will just confuse you.  In keeping with this tutorial I am just
  18. going to explain the minimum amount of commands you need to know about to 
  19. understand how the example program works.
  20.  
  21. There are at least four ways that we can load in a screen from disk, 
  22. I intend to cover three of them in this chapter as pictures play quite a
  23. large part in games as title screens, backgrounds etc.
  24. One way to load a picture is manually, we can press ESCAPE and type in 
  25.  
  26. LOADIFF "PICTURE NAME",0  
  27. ------------------------
  28. Which will load in a picture to screen 0.  Screen 0 is the screen you are 
  29. looking at and is created by Amos automatically. 
  30. You can create other screens but we will be covering that later so don`t 
  31. worry about that for now, also don`t worry about understanding the above 
  32. load command yet I will explain further in a minute. 
  33. Using this method is really only for checking or SPACKING a picture into a 
  34. memory bank which we will cover later, but I thought I would give it a quick
  35. mention here to ease you into the idea.
  36.  
  37. The second way to load a screen is from inside your program.  
  38. Let`s say you wish to load a title screen for the start of your game this is
  39. what you could do:
  40.  
  41. HIDE
  42. LOADIFF"DF0: PICS/SONIC.IFF",0
  43. WAIT KEY: EDIT
  44.  
  45. Yes that is all it is! We could squash all that on to one line if we wanted
  46. to, like this:
  47.  
  48. HIDE:LOADIFF"DF0: PICS/SONIC.IFF",0: WAIT KEY: EDIT
  49.  
  50. It`s not so easy to read but if you know what it does it`s OK.  This is just
  51. a habit I have, I prefer my programs to be like this as long as it is not a
  52. complex part of the program then it keeps it out of the way, you don`t have
  53. to do this so don`t worry about it.
  54.  
  55. OK here is a detailed examination of the above program:
  56.  
  57. HIDE
  58. ----
  59. HIDEs the mouse pointer
  60.  
  61. LOADIFF
  62. ------
  63. Tells Amos we want to LOAD an IFF picture file.
  64.  
  65. "DF0:
  66. ----
  67. Tells Amos the drive to use, change this to DF1: if you are using your 
  68. external drive.
  69.  
  70. PICS/SONIC.IFF"
  71. ---------------
  72. Is the name of the picture we want to load and it is stored in the PICS 
  73. drawer on this disk.
  74.  
  75. ,0
  76. --
  77. The screen to load the picture into for displaying, Screen 0 as explained 
  78. earlier is the default screen already created for us by Amos, as screen 0 is 
  79. the actual screen we are looking at we will see the picture displayed 
  80. automatically.
  81.  
  82. WAIT KEY: EDIT
  83. --------------
  84. Look up your notes or see the tips in EXAMPLE5.Amos
  85.  
  86.  
  87. OK if you read the above a few times and messed with EXAMPLE5.Amos I think
  88. you will have a good idea of how this all works.
  89.  
  90. I said earlier that we will cover three ways we to load a picture into Amos,
  91. well suppose you had written an art program and you had to let the user 
  92. LOAD in any picture he/she wanted.  The above examples would be useless
  93. because we can`t know the name of the file to load.  
  94. The solution is the Amos file selector, but before we can continue I am going
  95. to have to introduce you to the string, ($) the dollar sign, is known as 
  96. STRING and $ represents any letter or combination of letters to hold a 
  97. variable, look up your notes on variables.  The difference between the 
  98. numerical variable and the $ variable is obvious when you look at the 
  99. following examples:
  100.  
  101. Numerical variables we learnt about earlier:
  102.  
  103. A
  104. AVARIABLE
  105. TT
  106.  
  107. these can be assigned numbers that can be changed with INC, DEC etc.
  108.  
  109.  
  110. String variables:
  111.  
  112. A$
  113. AVARIABLE$
  114. TT$
  115.  
  116. These can be assigned text like this:
  117.  
  118. A$="LOTS OF TEXT AND STUFF, EVEN NUMBERS IF YOU LIKE 1234567890" 
  119.  
  120. Remember the PRINT command?  What we were doing, although not realizing it at
  121. the time, was assigning a string of text to tell PRINT what to PRINT, 
  122. in the same way we can assign text to a string variable, which is 
  123. normally inside the familiar quote marks " " If you are having trouble 
  124. wrapping your head around this concept then that makes you a normal human, 
  125. if you understand the string concept from the explanation above alone then 
  126. you are well on your way to stardom.  Right I am not going to dwell on 
  127. strings for too long as I don`t want to put you off, but you will see why I 
  128. had to mention strings in a moment.
  129.  
  130. Here is how to bring up the Amos file requester so that the user can select
  131. any picture file, load it and display it on screen:
  132.  
  133.  
  134. See EXAMPLE5_1.Amos
  135. -------------------
  136.  
  137. F$=fsel$("*.*","","LOAD A PICTURE")
  138. IF F$="" THEN EDIT
  139. HIDE
  140. LOAD IFF F$,0
  141. WAIT KEY: EDIT
  142.  
  143. Don`t panic, here`s the breakdown:
  144.  
  145.  
  146.  
  147. F$=fsel$("*.*","","LOAD A PICTURE")
  148. -----------------------------------
  149. Oh no! Look at that first line, it`s not so bad as it looks, honest guv!
  150. The good news is you don`t have to understand exactly how this line works,
  151. all you need to understand is that F$ will hold the exact filename of 
  152. whatever file the user has selected with the mouse, don`t worry about how 
  153. each part of this line works it`s irrelevant except that when you type it in
  154. it has to be exactly as above, all the quotes commas and brackets need to be
  155. in the right place, of course you can put in any text at the end of the line
  156. that you like such as "LOAD A PIC" or "SELECT A PICTURE" or nothing at all, 
  157. like this "" 
  158. this is two quotes which is an empty string, you also could change the first
  159. F$ to anything like FILESELECT$, FF$, WIBBLE$ or ABC$ but you will have to 
  160. change the F$ in line 4 to the same.
  161.  
  162. IF F$="" THEN EDIT
  163. ------------------
  164. In English this would sound like:
  165.  
  166. IF the string of text held in F$ is equal to nothing THEN jump to the EDITor.
  167.  
  168.  
  169. OK, it`s new concept time again the IF THEN structure is a powerful and 
  170. often use process, here are some real life examples:
  171.  
  172. IF the kettle has boiled     THEN switch it off
  173.  
  174. IF it is raining             THEN put hat on
  175.  
  176. IF petrol is low             THEN fill the tank
  177.  
  178. IF F$ equals nothing         THEN jump to editor
  179.  
  180. Just make a note that the IF THEN structure is as follows,
  181.  
  182. IF (do a check on something) THEN (execute something if true)
  183. --                           ----
  184.  
  185. The point is if the IF part (the question if you like) is true the THEN part
  186. of the line will be executed, furthermore if the IF part is false then Amos
  187. will ignore the rest of the line, example:
  188.  
  189. (the kettle isn`t boiling yet)
  190. IF the kettle has boiled       THEN switch it off
  191. continue with program because the IF part was false
  192.  
  193. So getting back to F$, IF F$ does NOT contain the empty string "" then Amos
  194. will not go to the EDITor but will continue on to the next instruction
  195. which is:
  196.  
  197. HIDE
  198. ----
  199. We are hiding the mouse just to keep things tidy, we didn`t HIDE it earlier
  200. in the program as the user needed to use it to select the file with.
  201.  
  202. LOAD IFF F$,0
  203. -------------
  204. LOADIFF tells Amos to prepare to LOAD an IFF picture.
  205. F$ holds the name of the file the user has selected.
  206. The 0 is the screen the picture will be loaded into and viewed, screen 0 is 
  207. the default screen as described earlier in this chapter.
  208.  
  209. WAIT KEY: EDIT
  210. --------------
  211. If all went well and the user selected an IFF file the picture should now be
  212. displayed on your screen, Amos will WAIT for a KEY press then return you to
  213. the EDITor.
  214.  
  215.  
  216.  
  217. End of chapter five.
  218.   
  219.